package com.thb.pay.manage.comm.controller;

import com.thb.pay.manage.service.FeginCommService;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;

public class BaseController {

    protected static final Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Autowired
    protected FeginCommService feginCommService;

    public List<Long> parseStrIdsToList(String resourceIds) {
        String[] resIds = resourceIds.split(",");
        List<Long> targetIds = new LinkedList<>();
        for (String resId : resIds) {
            if (NumberUtils.isDigits(resId)) {
                targetIds.add(Long.parseLong(resId));
            }
        }
        return targetIds;
    }

    /**
     * 传入金额元转成分
     *
     * @param value 前端填写的为元,可以为小数点2位
     */
    public Long handleAmount(String value) {
        Long amount = new BigDecimal(value.trim()).multiply(new BigDecimal(100)).longValue(); // // 转成分
        return amount;
    }

}
